package io.renren.modules.medical.controller;


import io.renren.common.result.Result;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.UpdateGroup;
import io.renren.modules.medical.service.PatientTreatmentInformationService;
import io.renren.modules.medical.vo.medicalVo.info.TreatmentInfoSaveVo;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 *
 * @author luosheng
 * @email luoshengshuai@foxmail.com
 * @date 2023-05-13 16:11:38
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("medical/patientTreatmentInfo")
public class PatientTreatmentInformationController {

    private final PatientTreatmentInformationService patientTreatmentInformationService;

    /**
     * 信息
     */
    @RequiresPermissions("treatmentinfo:info")
    @GetMapping("/info/{diseaseId}")
    public Result<TreatmentInfoSaveVo> info(@PathVariable("diseaseId") Long diseaseId){
        TreatmentInfoSaveVo treatmentInfoSaveVo = patientTreatmentInformationService.getTreatmentInfo(diseaseId);

        return Result.success(treatmentInfoSaveVo);
    }

    /**
     * 保存
     */
    @RequiresPermissions("treatmentinfo:save")
    @PostMapping("/save")
    public Result<String> save(@RequestBody @Validated(AddGroup.class)  TreatmentInfoSaveVo treatmentInfoSaveVo){
		patientTreatmentInformationService.saveTreatment(treatmentInfoSaveVo);

        return Result.success(null);
    }

    /**
     * 修改
     */
    @RequiresPermissions("treatmentinfo:update")
    @PostMapping("/update")
    public Result<String> update(@RequestBody @Validated(UpdateGroup.class) TreatmentInfoSaveVo treatmentInfoSaveVo){
		patientTreatmentInformationService.updateTreatment(treatmentInfoSaveVo);
        return Result.success(null);
    }

}
